import request from '@/utils/request'

// 新增题目
export function addQuestion(data) {
  console.log("addQuestion",data)
  return request({
    url: '/question2',
    method: 'post',
    data: data
  })
}

// 获取分类树
export function getCategoryTree() {
  return request({
    url: '/question2/category/tree',
    method: 'get'
  })
}

// 查询知识点列表
export function listKnowledge(params) {
  return request({
    url: '/question2/category/knowledge/list',
    method: 'get',
    params: params
  })
}

// 获取题型列表
export function listQuestionTypes() {
  return request({
    url: '/question2/type/list',
    method: 'get'
  })
}

// 查询题目列表
export function listQuestion(query) {
  return request({
    url: '/question2/list',
    method: 'get',
    params: query
  })
}

// 查询题目列表2
export function listQuestion2(query) {
  return request({
    url: '/question2/list2',
    method: 'get',
    params: query
  })
}

// 全文搜索题目
export function fulltextSearch(data) {
  return request({
    url: '/question2/fulltext/search',
    method: 'get',
    params: data
  })
}

// 获取题目详情
export function getQuestion(id) {
  return request({
    url: `/question2/${id}`,
    method: 'get'
  })
}

// 修改题目
export function updateQuestion(data) {
  return request({
    url: '/question2',
    method: 'put',
    data: data
  })
}

// 删除题目
export function deleteQuestion(ids) {
  return request({
    url: `/question2/${ids}`,
    method: 'delete'
  })
}

export function exportPdf(data) {
  return request({
    url: '/question2/export/pdf',
    method: 'post',
    data: data,
    responseType: 'blob'
  })
}

export function exportWord(data) {
  return request({
    url: '/question2/export/word2',
    method: 'post',
    data: data,
    responseType: 'blob'
  })
}


// 根据题目ID查找相似题目
export function getSimilarQuestionsById(questionId, pageQuery, threshold = 0.3) {
  return request({
    url: `/question2/get/similar/${questionId}`,
    method: 'get',
    params: {
      ...pageQuery,
      threshold
    }
  })
}

// 根据题目文本查找相似题目
export function getSimilarQuestionsByText(questionHtml, pageQuery, threshold = 0.3) {
  return request({
    url: '/question2/get/similar',
    method: 'post',
    params: {
      ...pageQuery,
      threshold
    },
    data: questionHtml

  })
}


